package com.lyf.scm.plan.domain.remote.promotion.facade;

import com.alibaba.fastjson.JSON;
import com.lyf.scm.common.enums.ResponseMsg;
import com.lyf.scm.plan.domain.remote.promotion.PromotionCoreRemote;
import com.lyf.scm.plan.domain.remote.promotion.dto.SinglePromotionItemDTO;
import com.rome.arch.core.clientobject.Response;
import com.rome.arch.core.exception.RomeException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 *
 * @author 李兵兵
 * @date 2020/09/27
 */
@Service
@Slf4j
public class PromotionCoreFacade {
    @Resource
    private PromotionCoreRemote promotionCoreRemote;

    public List<SinglePromotionItemDTO> singlePromotion(List<String> channelCodes){
        log.info("根据渠道查询对应的促销商品入参：channelCodes：{}", JSON.toJSONString(channelCodes));
        Response<List<SinglePromotionItemDTO>> response = promotionCoreRemote.singlePromotion(channelCodes);
        if(!ResponseMsg.SUCCESS.getCode().equals(response.getCode())){
            throw new RomeException(ResponseMsg.EXCEPTION_2008.getCode(),ResponseMsg.EXCEPTION_2008.getMsg());
        }
        return response.getData();
    }
}
